package com.haixiaoke.saas.workOrder.service;

import com.haixiaoke.saas.common.core.domain.AjaxResult;
import com.haixiaoke.saas.common.weChat.domain.ParseParam;

import com.haixiaoke.saas.workOrder.domain.WorkOrderPerson;
import com.haixiaoke.saas.workOrder.domain.WorkOrder;
import com.haixiaoke.saas.workOrder.domain.WorkOrderRecord;


import java.util.List;

/**
 * 工单Service接口
 *
 * @author panda
 * @date 2024-09-02
 */
public interface IWorkOrderService {
    /**
     * 查询工单
     *
     * @param workOrderId 工单主键
     * @return 工单
     */
    WorkOrder selectWorkOrderByWorkOrderId(String workOrderId);
    WorkOrder appletSelectWorkOrderByWorkOrderId(String workOrderId);

    /**
     * 查询工单列表
     *
     * @param workOrder 工单
     * @return 工单集合
     */
    List<WorkOrder> selectWorkOrderList(WorkOrder workOrder);

    /**
     * 新增工单
     *
     * @param workOrder 工单
     * @param phone 创建工单人的手机号
     * @return 结果
     */
    AjaxResult insertWorkOrder(WorkOrder workOrder, String phone);

    /**
     * 新增工单
     * @param workOrder
     * @return
     */
    int insertWorkOrder(WorkOrder workOrder);

    /**
     * 修改工单
     *
     * @param workOrder 工单
     * @return 结果
     */
    int updateWorkOrder(WorkOrder workOrder);

    /**
     * 编辑工单--有些字段没有非空校验
     * @param workOrder
     * @return
     */
    int editWorkOrder(WorkOrder workOrder);
    int flatUpdateWorkOrder(WorkOrder workOrder, String phone);

    /**
     * 批量删除工单
     *
     * @param workOrderIds 需要删除的工单主键集合
     * @return 结果
     */
     int deleteWorkOrderByWorkOrderIds(String[] workOrderIds);

    /**
     * 删除工单信息
     *
     * @param workOrderId 工单主键
     * @return 结果
     */
     int deleteWorkOrderByWorkOrderId(String workOrderId);

    /**
     * 创建工单支付二维码
     *
     * @param workOrderId
     * @return
     */
    AjaxResult createPayPicture(String workOrderId);

    /**
     * 扫码支付回调
     * @param parseParam
     */
    void weChatCallbackWorkOrderNativePay(ParseParam parseParam);

    /**
     * 驳回工单、作废工单
     * @param workOrderRecord
     * @param userName           企业端操作人姓名
     * @param flatUserName       C端操作人姓名
     * @return
     */
    AjaxResult rejectWorkOrder(WorkOrderRecord workOrderRecord, String userName, String flatUserName);

    /**
     * 派单、改派工单
     * @param workOrder
     * @return
     */
    AjaxResult dispatchWorkOrder(WorkOrder workOrder);

    /**
     * 接单
     * @param workOrderRecord    工单跟进记录
     * @param busUserId          工单员id
     * @param personTenantId     工单员的租户id
     * @return
     */
    AjaxResult receivedWorkOrder(WorkOrderRecord workOrderRecord, Long busUserId, String personTenantId);

    /**
     * 编辑紧急程度
     * @param workOrder
     * @return
     */
    AjaxResult editUrgencyDegree(WorkOrder workOrder, String phone);

    /**
     * 编辑上门时间
     * @param workOrder
     * @param phone
     * @return
     */
    AjaxResult editEstimateTime(WorkOrder workOrder, String phone);

    /**
     * 工单人员申请拒接、申请作废
     * @param workOrderRecord    工单跟进记录
     * @param userId             维修员id
     * @param tenantId           维修员的租户id
     * @return
     */
    AjaxResult requestRejectionWorkOrder(WorkOrderRecord workOrderRecord, Long userId, String tenantId);


    /**
     * 微信小程序支付回调
     * @param parseParam
     */
    void weChatCallbackWorkOrderUnifiedPay(ParseParam parseParam);

    /**
     * 审核拒接
     * @param workOrderRecord    工单跟进记录
     * @param username           操作人姓名
     * @return
     */
    AjaxResult auditDenialWorkOrder(WorkOrderRecord workOrderRecord, String username);

    /**
     * 编辑已接单、维修中工单
     * @param workOrder
     * @return
     */
    AjaxResult beingRepaired(WorkOrder workOrder);

    /**
     * 提交缴费单
     * @param workOrderId 工单id
     * @return
     */
    AjaxResult submitPaymentSlip(String workOrderId);

    /**
     * 维修员撤销拒接申请
     * @param workOrderRecord       工单跟进记录
     * @param busUserId             维修员id
     * @param maintenanceTenantId   维修员的租户id
     * @return
     */
    AjaxResult revocationRejectionWorkOrder(WorkOrderRecord workOrderRecord, Long busUserId, String maintenanceTenantId);

    /**
     * 小程序查询订单列表
     * @param workOrder 工单
     * @return
     */
    List<WorkOrder> flatSelectWorkOrderList(WorkOrder workOrder);
    /**
     * 上传缴费凭证
     *
     * @param workOrder
     * @param workOrderRecord
     * @return
     */
    AjaxResult addPaymentDocument(WorkOrder workOrder, WorkOrderRecord workOrderRecord);

    /**
     * 查询维修员未完成工单
     * @return
     */
    List<WorkOrder> checkWorkOrder(List<WorkOrderPerson> workOrderPersonList);

    /**
     * 小程序查询工单详情
     * @param workOrderId
     * @return
     */
    WorkOrder flatSelectWorkOrderByWorkOrderId(String workOrderId);

    /**
     * 工单超时任务
     */
    void workOrderOvertimeTask();

    /**
     * 小程序删除工单
     * @param workOrderId
     * @return
     */
    int softDeleteWorkOrderByWorkOrderId(String workOrderId);

    /**
     * 统计工单状态数量
     */
    AjaxResult countState(WorkOrder workOrder);

    /**
     * 查询维修人员待完成工单列表
     *
     * @param workOrderPersonId
     * @return
     */
    List<WorkOrder> selectPendingWorkOrderList(Long workOrderPersonId);

    /**
     * 导出工单列表查询
     * @param workOrder
     * @return
     */
    List<WorkOrder> exportSelectWorkOrderList(WorkOrder workOrder);

    /**
     * 申请临时密码
     * @param workOrderId
     * @param name
     * @param phone
     * @param busUserId
     * @return
     */
    AjaxResult applyTemporaryPassword(String workOrderId, String name, String phone,Long busUserId);

    /**
     * 工单人员--确认看房
     */
    AjaxResult confirmLookHouseWorkOrder(WorkOrder workOrder, Long userId, String tenantId);
}
